<?php
namespace BP\DA;
// require_once("java/io/BufferedReader.php");
// require_once("java/io/BufferedWriter.php");
// require_once("java/io/File.php");
// require_once("java/io/FileInputStream.php");
// require_once("java/io/FileWriter.php");
// require_once("java/io/IOException.php");
// require_once("java/io/InputStreamReader.php");
// require_once("java/io/Reader.php");
// require_once("java/math/BigDecimal.php");
// require_once("java/net/URL.php");
// require_once("java/text/DateFormat.php");
// require_once("java/text/DecimalFormat.php");
// require_once("java/text/ParseException.php");
// require_once("java/text/SimpleDateFormat.php");
// require_once("java/util/Calendar.php");
// require_once("java/util/Date.php");
// require_once("java/util/Hashtable.php");
// require_once("java/util/regex/Matcher.php");
// require_once("java/util/regex/Pattern.php");
// require_once("org/apache/commons/io/FileUtils.php");
// require_once("BP/Tools/DealString.php");
// require_once("BP/Tools/Json.php");
// require_once("BP/Tools/StringExpressionCalculate.php");
// require_once("BP/Tools/StringHelper.php");
// require_once("BP/Tools/StringUtils.php");
// require_once("BP/Tools/chs2py.php");
// require_once("BP/WF/Glo.php");
// require_once("BP/Web/WebUser.php");

class DataType {
	public static $RegEx_Replace_FirstXZ;	// String
	public static $RegEx_Replace_OnlySZX;	// String
	public static $RegEx_Replace_OnlyHSZX;	// String
	public static $AppString;	// int
	public static $AppInt;	// int
	public static $AppFloat;	// int
	public static $AppBoolean;	// int
	public static $AppDouble;	// int
	public static $AppDate;	// int
	public static $AppDateTime;	// int
	public static $AppMoney;	// int
	public static $AppRate;	// int
	public static function __staticinit() { // static class members
		self::$RegEx_Replace_FirstXZ = "^(_|[0-9])+";
		self::$RegEx_Replace_OnlySZX = "[\\u4e00-\\u9fa5]|[^0-9a-zA-Z_]";
		self::$RegEx_Replace_OnlyHSZX = "[^0-9a-zA-Z_\\u4e00-\\u9fa5]";
		self::$AppString = 1;
		self::$AppInt = 2;
		self::$AppFloat = 3;
		self::$AppBoolean = 4;
		self::$AppDouble = 5;
		self::$AppDate = 6;
		self::$AppDateTime = 7;
		self::$AppMoney = 8;
		self::$AppRate = 9;
	}
	public static function IsNullOrEmpty ($object) // [Object object]
	{
		if (($object == NULL) || (($object=="") ==  TRUE ) || (($object == "null") ==  TRUE ))
			return  TRUE ;
		return  FALSE ;
		
	}
	public static function ParseStringForNo () 
	{
		return NULL;
	}
	public static function GetSpanTime ($t1, $t2) // [Date t1, Date t2]
	{
		$diff = ($t2->getTime() - $t1->getTime());
		$diffSeconds = (($diff / 1000) % 60);
		$diffMinutes = (($diff / ((60 * 1000))) % 60);
		$diffHours = (($diff / (((60 * 60) * 1000))) % 24);
		$diffDays = ($diff / ((((24 * 60) * 60) * 1000)));
		$spanStr = "";
		if (($diffDays > 0))
			$spanStr += ($diffDays . "�?");
		if (($diffHours > 0))
			$spanStr += ($diffHours . "�?");
		if (($diffMinutes > 0))
			$spanStr += ($diffMinutes . "�?");
		if (($spanStr->length() == 0))
			$spanStr = "0�?";
		return $spanStr;
	}
	public static function WeekOfMonday ($dt) // [java.util.Date dt]
	{
		$monday = $Calendar->getInstance();
		$monday->setTime($dt);
		$FIRST_DAY_OF_WEEK = $Calendar->MONDAY;
		$monday->setFirstDayOfWeek($FIRST_DAY_OF_WEEK);
		$monday->set($Calendar->DAY_OF_WEEK, $Calendar->MONDAY);
		return $monday->getTime();
	}
	public static function WeekOfSunday ($dt) // [java.util.Date dt]
	{
		$cal = $Calendar->getInstance();
		$dayWeek = $cal->get($Calendar->DAY_OF_WEEK);
		if ((1 == $dayWeek))
		{
			$cal->add($Calendar->DAY_OF_MONTH, -1);
		}
		$cal->setFirstDayOfWeek($Calendar->MONDAY);
		$day = $cal->get($Calendar->DAY_OF_WEEK);
		$cal->add($Calendar->DATE, ($cal->getFirstDayOfWeek() - $day));
		$cal->add($Calendar->DATE, 6);
		return $cal->getTime();
	}
	public static function AddDays_Dateutiljava_I ($dt, $days) // [java.util.Date dt, int days]
	{
		if (($dt == NULL))
		{
			return NULL;
		}
		$cal = $Calendar->getInstance();
		$cal->setTime($dt);
		$mod = ($days % 5);
		$other = (($days / 5) * 7);
		for ($i = 0; ($i < $mod); ) 
		{
			$cal->add($Calendar->DATE, 1);
			switch ($cal->get($Calendar->DAY_OF_WEEK)) {
				case $Calendar->SUNDAY:
				case $Calendar->SATURDAY:
					break;
				default:
					++$i;
					break;
			}
		}
		if (($other > 0))
			$cal->add($Calendar->DATE, $other);
		return $cal->getTime();
	}
	public static function AddDays_String_I_TWay ($dt, $days, $tway) // [String dt, int days, TWay tway]
	{
	    return DataType::AddDays_Dateutiljava_I_TWay(DataType::ParseSysDate2DateTime($dt), $days, $tway);
	}
	public static function AddDays_Dateutiljava_I_TWay ($dt, $days, $tway) // [java.util.Date dt, int days, TWay tway]
	{
		if (($dt == NULL))
		{
			return NULL;
		}
		$cal = $Calendar->getInstance();
		$cal->setTime($dt);
		if (($tway == TWay::$AllDays))
		{
			$cal->add($Calendar->DAY_OF_MONTH, $days);
			return $cal->getTime();
		}
		$mod = ($days % 5);
		$other = (($days / 5) * 7);
		for ($i = 0; ($i < $mod); ) 
		{
			$cal->add($Calendar->DATE, 1);
			switch ($cal->get($Calendar->DAY_OF_WEEK)) {
				case $Calendar->SUNDAY:
				case $Calendar->SATURDAY:
					break;
				default:
					++$i;
					break;
			}
		}
		if (($other > 0))
			$cal->add($Calendar->DATE, $other);
		return $cal->getTime();
	}
	public static function AddDays_String_I ($sysdt, $days) // [String sysdt, int days]
	{
		$dt = DataType::ParseSysDate2DateTime($sysdt);
		return DataType::AddDays_Dateutiljava_I($dt, $days);
	}
	public static function WeekOfYear ($dtime) // [java.util.Date dtime]
	{
		$c = $Calendar->getInstance();
		$c->setTime($dtime);
		$week_of_year = $c->get($Calendar->WEEK_OF_YEAR);
		return ($week_of_year - 1);
	}
	public static function TurnToJiDuByDataTime ($dt) // [String dt]
	{
		if (($dt->length() <= 6))
		{
			throw new \Exception(("@要转化季度的日期格式不正�?:" . $dt));
		}
		$yf = $dt->substring(5, 7);
		if ((($yf->equals("01") || $yf->equals("02")) || $yf->equals("03")))
		{
			return ($dt->substring(0, 4) . "-03");
		}
		else
			if ((($yf->equals("04") || $yf->equals("05")) || $yf->equals("06")))
			{
				return ($dt->substring(0, 4) . "-06");
			}
			else
				if ((($yf->equals("07") || $yf->equals("08")) || $yf->equals("09")))
				{
					return ($dt->substring(0, 4) . "-09");
				}
				else
					if ((($yf->equals("10") || $yf->equals("11")) || $yf->equals("12")))
					{
						return ($dt->substring(0, 4) . "-12");
					}
					else
		return NULL;
	}
	public static function ToJson_DataTable ($dt) // [DataTable dt]
	{
		$jsonString = ""; // 
		$jsonString.=("[");
		$drc = $dt->Rows;
		for ($i = 0; ($i < $drc->size()); ++$i) 
		{
			$jsonString.=("{");
			for ($j = 0; ($j < $dt->Columns->size()); ++$j) 
			{
				$strKey = $dt->Columns->get($j)->ColumnName;
				if ($strKey->equals("BillNoFormat"))
				{
					continue;
				}
				$strValue = $drc->get($i)->getValue($j);
				$jsonString.=((("\"" . $strKey) . "\":"));
				if (($j < ($dt->Columns->size() - 1)))
				{
					$jsonString.=((("\"" . $strValue) . "\","));
				}
				else
				{
					$jsonString.=((("\"" . $strValue) . "\""));
				}
			}
			$jsonString.=("},");
		}
		$jsonString->deleteCharAt(($jsonString->length() - 1));
		$jsonString.=("]");
		return $jsonString;
	}
	public static function ToJson_DataTable_String ($dt, $jsonName) // [DataTable dt, String jsonName]
	{
		$jsonString = "";
		if (is_null($jsonName) || $jsonName == '')
		{
			$jsonName = $dt->TableName;
		}
		$jsonString += (((("{\"" . $jsonName) . "\":") . $Json->ToJson($dt)) . "}");
		return $jsonString;
	}
	public static function ToJsonEntityModel ($ht) // [Hashtable ht]
	{
		return $BP->Tools->Json->ToJsonEntityModel($ht);
	}
	public static function PraseToMB ($val) // [long val]
	{
		try 
		{
			return $Float->parseFloat($String->format("%0s", ($val / 1048576)));
		}
		catch (\Exception $e)
		{
			return 0;
		}
	}
	public static function PraseStringToFileName ($fileNameFormat) // [String fileNameFormat]
	{
		$strs = "+#?*\"<>/;,-:%~" /* from: "+#?*\"<>/;,-:%~".toCharArray() */;
		foreach ($strs as $c) 			$fileNameFormat = $fileNameFormat->replace($String->valueOf($c), "_");
		$strs = "：，。；？" /* from: "：，。；？".toCharArray() */;
		foreach ($strs as $c) 			$fileNameFormat = $fileNameFormat->replace($String->valueOf($c), "_");
		while (($fileNameFormat->contains(" ") ==  TRUE )) 
			$fileNameFormat = $fileNameFormat->replace(" ", "");
		$fileNameFormat = $fileNameFormat->replace("\t\n", "");
		$rBuilder = $fileNameFormat;
		$fileNameFormat = $String->valueOf($rBuilder);
		$fileNameFormat = $fileNameFormat->replace("__", "_");
		$fileNameFormat = $fileNameFormat->replace("__", "_");
		$fileNameFormat = $fileNameFormat->replace("__", "_");
		$fileNameFormat = $fileNameFormat->replace("__", "_");
		$fileNameFormat = $fileNameFormat->replace("__", "_");
		$fileNameFormat = $fileNameFormat->replace("__", "_");
		$fileNameFormat = $fileNameFormat->replace("__", "_");
		$fileNameFormat = $fileNameFormat->replace("__", "_");
		$fileNameFormat = $fileNameFormat->replace(" ", "");
		$fileNameFormat = $fileNameFormat->replace(" ", "");
		$fileNameFormat = $fileNameFormat->replace(" ", "");
		$fileNameFormat = $fileNameFormat->replace(" ", "");
		$fileNameFormat = $fileNameFormat->replace(" ", "");
		$fileNameFormat = $fileNameFormat->replace(" ", "");
		$fileNameFormat = $fileNameFormat->replace(" ", "");
		$fileNameFormat = $fileNameFormat->replace(" ", "");
		if (($fileNameFormat->length() > 240))
			$fileNameFormat = $fileNameFormat->substring(0, 240);
		return $fileNameFormat;
	}
	public static function PraseAtToInSql ($strs, $isNumber) // [String strs, boolean isNumber]
	{
		if ((DataType::IsNullOrEmpty($strs) ==  TRUE ))
			return "''";
		$strs = $strs->replace("@", "','");
		$strs = ($strs . "'");
		if (($strs->length() > 2))
			$strs = $strs->substring(2);
		if ($isNumber)
		{
			$strs = $strs->replace("'", "");
		}
		return $strs;
	}
	public static function DealSuperLink ($doc) // [String doc]
	{
		if (($doc . NULL))
		{
			return NULL;
		}
		return $doc;
	}
	public static function ConvertFileToByte ($fileName) // [String fileName]
	{
		$fs = $fileName;
		$fileSize = filesize($fs);
		$fi = NULL;
		$nowByte = array();
		try 
		{
			$offset = 0;
			$numRead = 0;
			while ((($offset < count($nowByte) /*from: nowByte.length*/) && (($numRead = $fi->read($nowByte, $offset, (count($nowByte) /*from: nowByte.length*/ - $offset))) >= 0))) 
			{
				$offset += $numRead;
			}
			if (($offset != count($nowByte) /*from: nowByte.length*/))
			{
				throw new \Exception(("Could not completely read file " . $fs));
			}
			
			$fi->close();
// 			$fi = new \FileInputStream($fs);
		}
		catch (\Exception $e)
		{
			Log::DebugWriteError(("DataType ConvertFileToByte()" . $e));
		}
		return $nowByte;
	}
	public static function WriteFile ($file, $Doc) // [String file, String Doc]
	{
		$fl = $file;
		if (file_exists($fl))
		{
			unlink($fl);
		}
		try 
		{
			fopen($fl, "w+");
			fwrite($fl, trim($Doc));// $FileUtils->write($fl, $Doc->trim(), "UTF-8");
		}
		catch (\Exception $e)
		{
			$e->getMessage(); // 
		}
	}
	public static function ReadURLContext ($url, $timeOut) // [String url, int timeOut]
	{
		$doc = "";
		try 
		{
		   $ch = curl_init($url);
		   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		   curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeOut);
		   $doc = curl_exec($ch);
		   curl_close($ch);
		}
		catch (\Exception $e)
		{
			$e->getMessage(); // 
		}
		return $doc;
	}
	public static function ReadTextFile_String ($filePath) // [String filePath]
	{
			/* match: String_String */
		return DataType::ReadTextFile_String_String($filePath, "UTF-8");
	}
	public static function ReadTextFile_String_String ($filePath, $codeType) // [String filePath, String codeType]
	{
// 		$in = NULL;
// 		$is = NULL;
		try 
		{
// 			$is = new InputStreamReader(new FileInputStream($filePath), $codeType);
// 			$in = new BufferedReader($is);
// 			$line = $in->readLine();
// 			$content = "";
// 			while (($line . NULL)) 
// 			{
// 				$content.=($line).=("\n");
// 				$line = $in->readLine();
// 			}
// 			return $content;
            return file_get_contents($filePath);
		}
		catch (\Exception $e)
		{
			return NULL;
		}
		
	}
	public static function SaveAsFile ($filePath, $doc) // [String filePath, String doc]
	{
		$fl = $filePath;
		if (file_exists($fl))
		{
			unlink($fl);
		}
		try 
		{
			fopen($fl, "w+");
// 			$fw = new FileWriter($fl->getAbsoluteFile());
// 			$bw = new BufferedWriter($fw);
// 			$bw->write($doc);
// 			$bw->close();
            fwrite($fl, $doc);
		}
		catch (\Exception $e)
		{
			$e->getMessage();
		}
		return  TRUE ;
	}
	public static function ReadTextFile2Html ($file) // [String file]
	{
			/* match: String */
		$doc = DataType::ReadTextFile_String($file);
		return DataType::ParseText2Html($doc);
	}
	public static function CheckIsChinese ($htmlstr) // [String htmlstr]
	{
	    if(preg_match("/[\x7f-\xff]/", $htmlstr)){
	        return TRUE;
	    }else {
	        return FALSE;
	    }
	}
	public static function Html2Text ($htmlstr) // [String htmlstr]
	{
		$htmlstr = $htmlstr->replace("<BR>", "\n");
		return $htmlstr->replace("&nbsp;", " ");
	}
	public static function ByteToString ($bye) // [byte[] bye]
	{
		$s = "";
		foreach ($bye as $b) 		{
		    $s += pack("H*", base_convert($b, 2, 16));// $s += (new Byte($b));
		}
		return $s;
	}
	public static function StringToByte ($s) // [String s]
	{
		$bs = array();
		$cs = $s->toCharArray();
		$i = 0;
		foreach ($cs as $c) 		{
			$bs[$i] = $c;
			++$i;
		}
		return $bs;
	}
	public static function GetPercent ($a, $b) // [java.math.BigDecimal a, java.math.BigDecimal b]
	{
        return round($a / $b, 2);
	}
	public static function GetWeek ($weekidx) // [int weekidx]
	{
		switch ($weekidx) {
			case 0:
				return "星期�?";
			case 1:
				return "星期�?";
			case 2:
				return "星期�?";
			case 3:
				return "星期�?";
			case 4:
				return "星期�?";
			case 5:
				return "星期�?";
			case 6:
				return "星期�?";
			default:
				throw new \Exception(("error weekidx=" . $weekidx));
		}
	}
	public static function GetABC ($abc) // [String abc]
	{
		if ($abc->equals("A"))
		{
			return "B";
		}
		else
			if ($abc->equals("B"))
			{
				return "C";
			}
			else
				if ($abc->equals("C"))
				{
					return "D";
				}
				else
					if ($abc->equals("D"))
					{
						return "E";
					}
					else
						if ($abc->equals("E"))
						{
							return "F";
						}
						else
							if ($abc->equals("F"))
							{
								return "G";
							}
							else
								if ($abc->equals("G"))
								{
									return "H";
								}
								else
									if ($abc->equals("H"))
									{
										return "I";
									}
									else
										if ($abc->equals("I"))
										{
											return "J";
										}
										else
											if ($abc->equals("J"))
											{
												return "K";
											}
											else
												if ($abc->equals("K"))
												{
													return "L";
												}
												else
													if ($abc->equals("L"))
													{
														return "M";
													}
													else
														if ($abc->equals("M"))
														{
															return "N";
														}
														else
															if ($abc->equals("N"))
															{
																return "O";
															}
															else
																if ($abc->equals("Z"))
																{
																	return "A";
																}
																else
																{
																	throw new \Exception(("abc error" . $abc));
																}
	}
	public static function SpanDays_String_String ($fromday, $today) // [String fromday, String today]
	{
		
		$date1 = \DateTime::createFromFormat('Y-m-d', $fromday)->getTimestamp();
		$date2 = \DateTime::createFromFormat('Y-m-d', $today)->getTimestamp();;
		
		$between_days = ((($date2 - $time1)) / (((1000 * 3600) * 24)));
		$days = round($between_days, 0);
		return $days;
	}
	public static function SpanQuarter ($_APFrom, $_APTo) // [String _APFrom, String _APTo]
	{
// 		$fmt = new SimpleDateFormat("yyyy-MM-dd");
// 		$fromdate = $fmt->parse(($_APFrom . "-01"));
// 		$todate = $fmt->parse(($_APTo . "-01"));
		$fromdate = \DateTime::createFromFormat('Y-m-d', $_APFrom . "-01");
		$todate = \DateTime::createFromFormat('Y-m-d', $_APTo . "-01");
		$i = 0;
		
		if ($fromdate>$todate)
		{
			throw new \Exception((((("选择出错！起始时�?" . $_APFrom) . "不能大于终止时期") . $_APTo) . "!"));
		}
		while (($fromdate-$todate) <= 0) 
		{
			++$i;
			$fromdate = strtotime("+1 month", $fromdate);
		}
		$j = ((($i + 2)) / 3);
		return $j;
	}
	public static function SpanDays_String ($data1) // [String data1]
	{
		$time1 = \DateTime::createFromFormat('Y-m-d', $data1);
		$time2 = time();
		$between_days = ((($time2 - $time1)) / (((1000 * 3600) * 24)));
		$days = round($between_days, 2);
	
		return $days;
	}
	public static function CheckIsFieldOrTableName ($str) // [String str]
	{
		$s = $str->substring(0, 1);
		if (DataType::IsNumStr($s))
		{
			return  FALSE ;
		}
		$chars = "~!@#$%^&*()_+`{}|:'<>?[];',./";
		if ($chars->contains($s))
		{
			return  FALSE ;
		}
		return  TRUE ;
	}
	public static function ParseText2Html ($val) // [String val]
	{
		return $val->replace("\n", "<BR>")->replace("~", "'");
	}
	public static function ParseHtmlToText ($val) // [String val]
	{
		if (($val . NULL))
		{
			return $val;
		}
		$val = $val->replace("&nbsp;", " ");
		$val = $val->replace("  ", " ");
		$val = $val->replace("</td>", "");
		$val = $val->replace("</TD>", "");
		$val = $val->replace("</tr>", "");
		$val = $val->replace("</TR>", "");
		$val = $val->replace("<tr>", "");
		$val = $val->replace("<TR>", "");
		$val = $val->replace("</font>", "");
		$val = $val->replace("</FONT>", "");
		$val = $val->replace("</table>", "");
		$val = $val->replace("</TABLE>", "");
		$val = $val->replace("<BR>", "\n\t");
		$val = $val->replace("<BR>", "\n\t");
		$val = $val->replace("&nbsp;", " ");
		$val = $val->replace("<BR><BR><BR><BR>", "<BR><BR>");
		$val = $val->replace("<BR><BR><BR><BR>", "<BR><BR>");
		$val = $val->replace("<BR><BR>", "<BR>");
		$chs = $val->toCharArray();
		$isStartRec =  FALSE ;
		$recStr = "";
		foreach ($chs as $c) 		{
			if (($c . '<'))
			{
				$recStr = "";
				$isStartRec =  TRUE ;
			}
			if ($isStartRec)
			{
				$recStr += (new Character($c));
			}
			if (($c . '>'))
			{
				$isStartRec =  FALSE ;
				if ($recStr->equals(""))
				{
					$isStartRec =  FALSE ;
					continue;
				}
				$market = $recStr->toLowerCase();
				if ($market->contains("<img"))
				{
					$isStartRec =  FALSE ;
					$recStr = "";
					continue;
				}
				else
				{
					$val = $val->replace($recStr, "");
					$isStartRec =  FALSE ;
					$recStr = "";
				}
			}
		}
		$val = $val->replace("字体：大中小", "");
		$val = $val->replace("字体:大中�?", "");
		$val = $val->replace("  ", " ");
		$val = $val->replace("\t", "");
		$val = $val->replace("\n", "");
		$val = $val->replace("\r", "");
		return $val;
	}
	public static function PraseStringToUrlFileName ($fileName) // [String fileName]
	{
		if (($fileName->lastIndexOf('\\') == -1))
		{
			$fileName = DataType::PraseStringToUrlFileNameExt($fileName, "%", "%25");
			$fileName = DataType::PraseStringToUrlFileNameExt($fileName, "+", "%2B");
			$fileName = DataType::PraseStringToUrlFileNameExt($fileName, " ", "%20");
			$fileName = DataType::PraseStringToUrlFileNameExt($fileName, "/", "%2F");
			$fileName = DataType::PraseStringToUrlFileNameExt($fileName, "?", "%3F");
			$fileName = DataType::PraseStringToUrlFileNameExt($fileName, "#", "%23");
			$fileName = DataType::PraseStringToUrlFileNameExt($fileName, "&", "%26");
			$fileName = DataType::PraseStringToUrlFileNameExt($fileName, "=", "%3D");
			$fileName = DataType::PraseStringToUrlFileNameExt($fileName, " ", "%20");
			return $fileName;
		}
		$filePath = $fileName->substring(0, $fileName->lastIndexOf('\\'));
		$fName = $fileName->substring($fileName->lastIndexOf('\\'));
		$fName = DataType::PraseStringToUrlFileNameExt($fName, "%", "%25");
		$fName = DataType::PraseStringToUrlFileNameExt($fName, "+", "%2B");
		$fName = DataType::PraseStringToUrlFileNameExt($fName, " ", "%20");
		$fName = DataType::PraseStringToUrlFileNameExt($fName, "/", "%2F");
		$fName = DataType::PraseStringToUrlFileNameExt($fName, "?", "%3F");
		$fName = DataType::PraseStringToUrlFileNameExt($fName, "#", "%23");
		$fName = DataType::PraseStringToUrlFileNameExt($fName, "&", "%26");
		$fName = DataType::PraseStringToUrlFileNameExt($fName, "=", "%3D");
		$fName = DataType::PraseStringToUrlFileNameExt($fName, " ", "%20");
		return ($filePath . $fName);
	}
	protected static function PraseStringToUrlFileNameExt ($fileName, $val, $replVal) // [String fileName, String val, String replVal]
	{
		$fileName = $fileName->replace($val, $replVal);
		$fileName = $fileName->replace($val, $replVal);
		$fileName = $fileName->replace($val, $replVal);
		$fileName = $fileName->replace($val, $replVal);
		$fileName = $fileName->replace($val, $replVal);
		$fileName = $fileName->replace($val, $replVal);
		$fileName = $fileName->replace($val, $replVal);
		$fileName = $fileName->replace($val, $replVal);
		return $fileName;
	}
	public static function ParseStringToPinyin ($exp) // [String exp]
	{
		switch ($exp) {
			case "电话":
				return "Tel";
			case "地址":
				return "Addr";
			case "年龄":
				return "Age";
			case "邮件":
				return "Email";
			case "单价":
				return "DanJia";
			case "金额":
				return "JinE";
			case "单据编号":
				return "BillNo";
			default:
				break;
		}
		$exp = $exp->replace("单价", "DanJia");
		$exp = $exp->replace("单件", "DanJian");
		$exp = $exp->replace("单个", "DanGe");
		$exp = $exp->trim();
		$pinYin = "";
		$str = NULL;
		$chars = $exp->toCharArray();
		foreach ($chars as $c) 		{
			try 
			{
				$str = $String->valueOf($c);
				$str = $chs2py->convert((new Character($c)));
				$pinYin += ($str->substring(0, 1)->toUpperCase() + $str->substring(1));
			}
			catch (\Exception $e)
			{
				$pinYin += $c;
			}
		}
		return $pinYin;
	}
	public static function ParseStringToPinyinWordFirst ($str) // [String str]
	{
		try 
		{
			$_Temp = "";
			for ($i = 0; ($i < $str->length()); ++$i) 
			{
				$_Temp = ($_Temp .DataType::ParseStringToPinyin($str->substring($i, ($i + 1))));
			}
			return $_Temp;
		}
		catch (\RuntimeException $ex)
		{
			throw new \Exception((("@错误�?" . $str) . "，不能转换成拼音�?"));
		}
	}
	public static function ParseStringToPinyinJianXie ($str) // [String str]
	{
		$str = $str->replaceAll(" ", "");
		try 
		{
			$_Temp = "";
			for ($i = 0; ($i < $str->length()); ++$i) 
			{
				$_Temp +=DataType::ParseStringToPinyin($str->substring($i, ($i + 1)))->substring(0, 1);
			}
			return $_Temp;
		}
		catch (\RuntimeException $ex)
		{
			throw new \Exception((("@错误�?" . $str) . "，不能转换成拼音�?"));
		}
	}
	public static function ParseExpToDecimal ($exp) // [String exp]
	{
		$bigDecimal = new BigDecimal(0);
		if (trim($exp)==="")
		{
			throw new \Exception("DataType.ParseExpToDecimal要转换的表达式为空�??");
		}
		$exp = $exp->replace("+-", "-");
		$exp = $exp->replace("�?", "");
		$exp = $exp->replace("\n", "");
		$exp = $exp->replace("\t", "");
		$exp = $exp->replace("�?", "+");
		$exp = $exp->replace("�?", "-");
		$exp = $exp->replace("�?", "*");
		$exp = $exp->replace("�?", "/");
		$exp = $exp->replace("�?", ")");
		$exp = $exp->replace("�?", "(");
		$exp = $exp->replace(".00.00", "00");
		$exp = $exp->replace("--", "- -");
		if (($exp->indexOf("@") != -1))
		{
			return $bigDecimal;
		}
		$val = $exp->substring(0, 1);
		if ($val->equals("-"))
		{
			$exp = $exp->substring(1);
		}
		$exp = $exp->replace("*100%", "*1");
		try 
		{
			$bigDecimal1 = new BigDecimal($exp);
			return $bigDecimal1;
		}
		catch (\Exception $e)
		{
			Log::DebugWriteError(("ParseExpToDecimal " . $e->getMessage()));
		}
		try 
		{
			$sql = (("SELECT  " . $exp) . " as Num  ");
			foreach (DBType as $g) 			{
				switch ($g) {
					case $MSSQL:
						break;
					case $Oracle:
						$sql = (("SELECT  " . $exp) . " NUM from DUAL ");
						return DBAccess::RunSQLReturnValDecimal_String_BigDecimal_I($sql, $bigDecimal, 2);
					default:
						break;
				}
			}
		}
		catch (\RuntimeException $ex)
		{
			return $bigDecimal;
		}
		$exp = $exp->replace("-0", "");
		try 
		{
			$sc = new StringExpressionCalculate();
			return new BigDecimal($sc->TurnToDecimal($exp));
		}
		catch (\RuntimeException $ex)
		{
			if (($exp->indexOf("/") != -1))
			{
				return $bigDecimal;
			}
			throw new \Exception(((("表达�?(\"" . $exp) . "\")计算错误�?") . $ex->getMessage()));
		}
	}
	public static function ParseFloatToCash ($money) // [float money]
	{
		if (($money == 0))
		{
			return "零圆零角零分";
		}
		$d = new DealString();
		$d->setInputString((new Float($money)));
		$d->ConvertToChineseNum();
		return $d->getOutString();
	}
	public static function ParseFloatToRMB ($money) // [float money]
	{
		if (($money == 0))
		{
			return "零圆零角零分";
		}
		$d = new DealString();
		$d->setInputString((new Float($money)));
		$d->ConvertToChineseNum();
		return $d->getOutString();
	}
	public function Parse ($dataStr) // [String dataStr]
	{
		return new Date($java->util->Date->parse($dataStr));
	}
	public static function getSysDataFormat () 
	{
		return "yyyy-MM-dd";
	}
	public static function addMonths ($month) // [int month]
	{

		return strtotime("+1 month", time());
	}
	public static function getCurrentDate () 
	{
		return date_format(time(), 'Y-m-d');
	}
	public static function getCurrentDateTime () 
	{
		return date_format(time(), 'Y-m-d H:i');
	}
	public static function getDate () 
	{
		return time();
	}
	public static function getCurrentTime () 
	{
		return date_format(time(), 'H:i');
	}
	public static function dateToStr ($date, $sFormat) // [Date date, String sFormat]
	{
		if ((NULL == $date))
			return "";
// 		$df = new SimpleDateFormat($sFormat);
// 		return $df->format($date);
		return date($sFormat, $date);
	}
	public static function stringToDate ($str) // [String str]
	{
		if ($str == "")
			return NULL;
			return \DateTime::createFromFormat('Y-m-d', $str)->getTimestamp();
	}
	public static function getCurrentTimeQuarter () 
	{
// 		$dt = new Date();
// 		$matter = new SimpleDateFormat("hh:mm");
// 		$date = $matter->format($dt);
		$date = date('H:i', time());
		return $date;
	}
	public static function ParseTime2TimeQuarter ($time) // [String time]
	{
		$hh = $time->substring(0, 3);
		$mm = $Integer->parseInt($time->substring(3, 5));
		if (($mm == 0))
		{
			return ($hh . "00");
		}
		if (($mm < 15))
		{
			return ($hh . "00");
		}
		if ((($mm >= 15) && ($mm < 30)))
		{
			return ($hh . "15");
		}
		if ((($mm >= 30) && ($mm < 45)))
		{
			return ($hh . "30");
		}
		if ((($mm >= 45) && ($mm < 60)))
		{
			return ($hh . "45");
		}
		return $time;
	}
	public static function getCurrentDay () 
	{
// 		$dt = new Date();
// 		$matter = new SimpleDateFormat("dd");
// 		$date = $matter->format($dt);
		return date_format(time(), 'd');
	}
	public static function getCurrentAP () 
	{
// 		$dt = new Date();
// 		$matter = new SimpleDateFormat("yyyy-MM");
// 		$date = $matter->format($dt);
		return date_format(time(), 'Y-m');
	}
	public static function getCurrentYear () 
	{
// 		$dt = new Date();
// 		$matter = new SimpleDateFormat("yyyy");
// 		$date = $matter->format($dt);
		return date_format(time(), 'Y');
	}
	public static function getCurrentMonth () 
	{
// 		$dt = new Date();
// 		$matter = new SimpleDateFormat("MM");
// 		$date = $matter->format($dt);
		return date_format(time(), 'm');
	}
	public static function getCurrentYearMonth () 
	{
		return date_format(time(), 'Y-m');;
	}
	public static function GetJDByMM ($mm) // [String mm]
	{
		$jd = "01";
		if ((($mm->equals("01") || $mm->equals("02")) || $mm->equals("03")))
		{
			$jd = "01";
		}
		else
			if ((($mm->equals("04") || $mm->equals("05")) || $mm->equals("06")))
			{
				$jd = "04";
			}
			else
				if ((($mm->equals("07") || $mm->equals("08")) || $mm->equals("09")))
				{
					$jd = "07";
				}
				else
					if ((($mm->equals("10") || $mm->equals("11")) || $mm->equals("12")))
					{
						$jd = "10";
					}
					else
					{
						throw new \Exception(("@不是有效的月份格�?" . $mm));
					}
		return $jd;
	}
	public static function getCurrentAPOfJD () 
	{
	    $dt = time();
		$date = date_format($dt, 'Y');
		$date1 = date_format($dt, 'm');
		$date2 = DataType::GetJDByMM($date1);
		return (($date . "-") . $date2);
	}
	public static function getCurrentAPOfJDOfFrontFamily () 
	{
// 		$cd = $Calendar->getInstance();
// 		$cd->set($Calendar->DAY_OF_MONTH, -3);
// 		$cd->add($Calendar->MONTH, -3);
// 		$d = $cd->getTime();
// 		$matter = new SimpleDateFormat("yyyy");
// 		$date = $matter->format($d);
// 		$matter1 = new SimpleDateFormat("MM");
// 		$date1 = $matter1->format($d);
// 		$date2 = DataType::GetJDByMM($date1);
		
		$d = strtotime("-3 month -3 day");
        $date = date('Y', $d);
        $date1 = date('m', $d);
        $date2 = DataType::GetJDByMM($date1);
		return (($date . "-") . $date2);
	}
	public static function getCurrentNYOfPrevious () 
	{
// 		$format = new SimpleDateFormat("yyyy-MM");
// 		$calendar = $Calendar->getInstance();
// 		$calendar->add($Calendar->MONTH, -1);
// 		$date = $format->format($calendar->getTime());
		
// 		return $date;
		return date('Y-m', strtotime('-1 month'));
	}
	public static function getCurrentDataTime () 
	{
// 		$dt = new Date();
// 		$matter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
// 		$date = $matter->format($dt);
		
// 		return $date;
	    return date('Y-m-d H:i', time());
	}
	public static function getCurrentDateByFormart ($formart) // [String formart]
	{
// 		$dt = new Date();
// 		$matter = new SimpleDateFormat($formart);
// 		$date = $matter->format($dt);
// 		return $date;
	    return date($formart, time());
	}
	public static function getDateByFormart ($date, $formart) // [Date date, String formart]
	{
// 		$matter = new SimpleDateFormat($formart);
// 		$dateStr = $matter->format($date);
// 		return $dateStr;
	    return date($formart, $date);
	}
	public static function getCurrentDataTimeCNOfShort () 
	{
		$matter = new SimpleDateFormat("yy年MM月dd�? HH时mm�?");
		return $matter->format(new Date());
	}
	public static function getCurrentDataTimeCNOfLong () 
	{
		$matter = new SimpleDateFormat("yy年MM月dd�? HH时mm分ss�?");
		return $matter->format(new Date());
	}
	public static function getCurrentDataCNOfShort () 
	{
		$matter = new SimpleDateFormat("yy年MM月dd�?");
		return $matter->format(new Date());
	}
	public static function getCurrentDataCNOfLong () 
	{
		$matter = new SimpleDateFormat("yyyy年MM月dd�?");
		return $matter->format(new Date());
	}
	public static function getCurrentDataTimeCN () 
	{
		$matter = new SimpleDateFormat(DataType::getSysDataFormatCN());
		$calendar = $Calendar->getInstance();
		$dayOfWeek = $calendar->get($Calendar->DAY_OF_WEEK);
		return (($matter->format(new Date()) . "�?") . DataType::GetWeekName($dayOfWeek));
	}
	protected static function GetWeekName ($dw) // [int dw]
	{
	    $dayNames = ["星期�?", "星期�?", "星期�?", "星期�?", "星期�?", "星期�?", "星期�?"];
		return $dayNames[$dw];
	}
	public static function getCurrentDataTimess () 
	{
// 		$matter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// 		return $matter->format(new Date());
		return date('Y-m-d H:i:s', time());
	}
	public static function ParseSysDateTime2SysDate ($sysDateformat) // [String sysDateformat]
	{
		try 
		{
			return $sysDateformat->substring(0, 10);
		}
		catch (\RuntimeException $ex)
		{
			throw new \Exception(((("日期格式错误:" . $sysDateformat) . " errorMsg=") . $ex->getMessage()));
		}
	}
	public static function ParseSysDate2DateTime ($sysDateformat) // [String sysDateformat]
	{
		if ((($sysDateformat . NULL) . ($sysDateformat->trim()->length() == 0)))
		{
			return new Date();
		}
		try 
		{
			if (($sysDateformat->length() > 10))
			{
				return DataType::ParseSysDateTime2DateTime($sysDateformat);
			}
			$sysDateformat = $sysDateformat->trim();
			$strs = NULL;
			if (($sysDateformat->indexOf("-") != -1))
			{
				$strs = $sysDateformat->split("[-]", -1);
			}
			if (($sysDateformat->indexOf("/") != -1))
			{
				$strs = $sysDateformat->split("[/]", -1);
			}
			$year = $Integer->parseInt($strs[0]);
			$month = $Integer->parseInt($strs[1]);
			$day = $Integer->parseInt($strs[2]);
			return new Date($year, $month, $day, 0, 0, 0);
		}
		catch (\RuntimeException $ex)
		{
			throw new \Exception((((("日期[" . $sysDateformat) . "]转换出现错误:") . $ex->getMessage()) . "无效的日期是格式�?"));
		}
	}
	public static function ParseSysDateTime2DateTime ($sysDateformat) // [String sysDateformat]
	{
		try 
		{
			return $org->apache->commons->lang->time->DateUtils->parseDate($sysDateformat, array( "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM", "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM", "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM", "yyyy", "yyyy年MM月dd�?", "yyyy年MM月dd�? HH时mm分ss�?", "yyyy年MM月dd�? HH时mm�?", "yyyy年MM�?" ));
		}
		catch (\Exception $ex)
		{
			$ex->printStackTrace();
			return NULL;
		}
	}
	public static function GetSpanDays ($dtoffrom, $dtofto) // [String dtoffrom, String dtofto]
	{
		$dtfrom = DataType::ParseSysDate2DateTime($dtoffrom);
		$dtto = DataType::ParseSysDate2DateTime($dtofto);
		$diff = ($dtto->getTime() - $dtfrom->getTime());
		$day = ($diff / ((((1000 * 60) * 60) * 24)));
		$ds = $day;
		return $ds;
	}
	public static function GetSpanMinute_String_String ($fromdatetim, $toDateTime) // [String fromdatetim, String toDateTime]
	{
		$dtfrom = DataType::ParseSysDateTime2DateTime($fromdatetim);
		$dtto = DataType::ParseSysDateTime2DateTime($toDateTime);
		$diff = ($dtto->getTime() - $dtfrom->getTime());
		$day = ($diff / ((((24 * 60) * 60) * 1000)));
		$hour = ((($diff / (((60 * 60) * 1000))) - ($day * 24)));
		$min = ((((($diff / ((60 * 1000)))) - (($day * 24) * 60)) - ($hour * 60)));
		$mn = $min;
		return $mn;
	}
	public static function GetSpanMinute_String ($fromdatetim) // [String fromdatetim]
	{
		$dtfrom = DataType::ParseSysDateTime2DateTime($fromdatetim);
		$dtto = new Date();
		$diff = ($dtto->getTime() - $dtfrom->getTime());
		$day = ($diff / ((((24 * 60) * 60) * 1000)));
		$hour = ((($diff / (((60 * 60) * 1000))) - ($day * 24)));
		$min = ((((($diff / ((60 * 1000)))) - (($day * 24) * 60)) - ($hour * 60)));
		$mn = $min;
		$hu = $hour;
		return ($mn + ($hu * 60));
	}
	public static function getSysDataTimeFormat () 
	{
		return "yyyy-MM-dd HH:mm";
	}
	public static function getSysDataTimessFormat () 
	{
		return "yyyy-MM-dd HH:mm:ss";
	}
	public static function getSysDataFormatCN () 
	{
		return "yyyy年MM月dd�?";
	}
	public static function getSysDatatimeFormatCN () 
	{
		return "yyyy年MM月dd�? HH时mm�?";
	}
	public static function GetDBUrlByString ($strDBUrl) // [String strDBUrl]
	{
		return DBUrlType::$AppCenterDSN;
	}
	public static function GetDataTypeByString ($datatype) // [String datatype]
	{
		if ($datatype->equals("AppBoolean"))
		{
			return DataType::$AppBoolean;
		}
		else
			if ($datatype->equals("AppDate"))
			{
				return DataType::$AppDate;
			}
			else
				if ($datatype->equals("AppDateTime"))
				{
					return DataType::$AppDateTime;
				}
				else
					if ($datatype->equals("AppDouble"))
					{
						return DataType::$AppDouble;
					}
					else
						if ($datatype->equals("AppFloat"))
						{
							return DataType::$AppFloat;
						}
						else
							if ($datatype->equals("AppInt"))
							{
								return DataType::$AppInt;
							}
							else
								if ($datatype->equals("AppMoney"))
								{
									return DataType::$AppMoney;
								}
								else
									if ($datatype->equals("AppString"))
									{
										return DataType::$AppString;
									}
									else
									{
										throw new \Exception((("@没有此类型[" . DataType::$AppString) . "]"));
									}
	}
	public static function GetDataTypeDese ($datatype) // [int datatype]
	{
		if ($WebUser->getSysLang()->equals("CH"))
		{
			switch ($datatype) {
				case DataType::$AppBoolean:
					return "布尔(Int)";
				case DataType::$AppDate:
					return "日期nvarchar";
				case DataType::$AppDateTime:
					return "日期时间nvarchar";
				case DataType::$AppDouble:
					return "双精�?(double)";
				case DataType::$AppFloat:
					return "浮点(float)";
				case DataType::$AppInt:
					return "整型(int)";
				case DataType::$AppMoney:
					return "货币(float)";
				case DataType::$AppString:
					return "字符(nvarchar)";
				default:
					throw new \Exception("@没有此类�?");
			}
		}
		switch ($datatype) {
			case DataType::$AppBoolean:
				return "Boolen";
			case DataType::$AppDate:
				return "Date";
			case DataType::$AppDateTime:
				return "Datetime";
			case DataType::$AppDouble:
				return "Double";
			case DataType::$AppFloat:
				return "Float";
			case DataType::$AppInt:
				return "Int";
			case DataType::$AppMoney:
				return "Money";
			case DataType::$AppString:
				return "Nvarchar";
			default:
				throw new \Exception("@没有此类�?");
		}
	}
	public static function StringToDateStr ($str) // [String str]
	{
		return "";
	}
	public static function GenerSpace ($spaceNum) // [int spaceNum]
	{
		if (($spaceNum <= 0))
		{
			return "";
		}
		$strs = "";
		while (($spaceNum != 0)) 
		{
			$strs += "&nbsp;&nbsp;";
			--$spaceNum;
		}
		return $strs;
	}
	public static function getShangCurrentNYOfPrevious () 
	{
// 		$format = new SimpleDateFormat("yyyy-MM");
// 		$calendar = $Calendar->getInstance();
// 		$calendar->add($Calendar->MONTH, -2);
// 		$date = $format->format($calendar->getTime());
		$date = strtotime('-2 month', time());
		date_format($date, 'Y-m');
		return $date;
	}
	public static function getCurrentWeek () 
	{
		$c = $Calendar->getInstance();
		$i = $c->get($Calendar->WEEK_OF_YEAR);
		return $i;
	}
	public static function GenerBR ($spaceNum) // [int spaceNum]
	{
		$strs = "";
		while (($spaceNum != 0)) 
		{
			$strs += "<BR>";
			--$spaceNum;
		}
		return $strs;
	}
	public static function IsImgExt ($ext) // [String ext]
	{
		$ext = $ext->replace(".", "")->toLowerCase();
		if ((((((((((($ext->equals("jpg") || $ext->equals("gif")) || $ext->equals("jepg")) || $ext->equals("bmp")) || $ext->equals("png")) || $ext->equals("tif")) || $ext->equals("gsp")) || $ext->equals("mov")) || $ext->equals("psd")) || $ext->equals("tiff")) || $ext->equals("wmf")))
		{
			return  TRUE ;
		}
		else
		{
			return  FALSE ;
		}
	}
	public static function IsVoideExt ($ext) // [String ext]
	{
		$ext = $ext->replace(".", "")->toLowerCase();
		if (((((((((((($ext->equals("mp3") || $ext->equals("mp4")) || $ext->equals("asf")) || $ext->equals("wma")) || $ext->equals("rm")) || $ext->equals("rmvb")) || $ext->equals("mpg")) || $ext->equals("wmv")) || $ext->equals("quicktime")) || $ext->equals("avi")) || $ext->equals("flv")) || $ext->equals("mpeg")))
		{
			return  TRUE ;
		}
		else
		{
			return  FALSE ;
		}
	}
	public static function IsNumStr ($str) // [String str]
	{
		$pattern = $Pattern->compile("[0-9]*");
		$isNum = $pattern->matcher($str);
		if (!$isNum->matches())
		{
			return  FALSE ;
		}
		return  TRUE ;
	}
	public static function IsQS ($num) // [int num]
	{
		$ii = 0;
		for ($i = 0; ($i < 500); ++$i) 
		{
			if (($num == $ii))
			{
				return  FALSE ;
			}
			$ii = ($ii + 2);
		}
		return  TRUE ;
	}
	public static function StringToBoolean ($str) // [String str]
	{
		if (((($str . NULL) . $str->equals("")) . $str->equals(",nbsp;")))
		{
			return  FALSE ;
		}
		if (($str->equals("0") || $str->equals("1")))
		{
			if ($str->equals("0"))
			{
				return  FALSE ;
			}
			else
			{
				return  TRUE ;
			}
		}
		else
			if (($str->equals("true") || $str->equals("false")))
			{
				if ($str->equals("false"))
				{
					return  FALSE ;
				}
				else
				{
					return  TRUE ;
				}
			}
			else
				if (($str->equals("�?") || $str->equals("�?")))
				{
					if ($str->equals("�?"))
					{
						return  FALSE ;
					}
					else
					{
						return  TRUE ;
					}
				}
				else
				{
					throw new \Exception((("@要转换的[" . $str) . "]不是bool 类型"));
				}
	}
	public static function ParseSysDate2DateTimeFriendly ($sysDateformat) // [String sysDateformat]
	{
		return DataType::DateStringFromNow_Date(DataType::ParseSysDateTime2DateTime($sysDateformat));
	}
	public function DateStringFromNow_String ($dt) // [String dt]
	{
		return $this->DateStringFromNow_Date(DataType::ParseSysDateTime2DateTime($dt));
	}
	public static function DateStringFromNow_Date ($dt) // [Date dt]
	{
		$date = time();
		$spanTotal = ($date - $dt->getTime());
		$spanSeconds = ($spanTotal / 1000);
		$spanMinutes = (($spanTotal / 1000) / 60);
		$spanHours = ((($spanTotal / 1000) / 60) / 60);
		$spanDays = (((($spanTotal / 1000) / 60) / 60) / 24);
		if (($spanDays > 60))
		{
			return $dt;
		}
		else
		{
			if (($spanDays > 30))
			{
				return "1个月前";
			}
			else
			{
				if (($spanDays > 14))
				{
					return "2周前";
				}
				else
				{
					if (($spanDays > 7))
					{
						return "1周前";
					}
					else
					{
						if (($spanDays > 1))
						{
						    
// 							return $String->format("%1$s天前", floor$spanDays);
						    return floor($spanDays) . "天前";
						}
						else
						{
							if (($spanHours > 1))
							{
// 								return $String->format("%1$s小时�?", floor$spanHours);
                                return floor($spanHours) . "小时前";
							}
							else
							{
								if (($spanMinutes > 1))
								{
// 									return $String->format("%1$s分钟�?", floor$spanMinutes);
								    return floor($spanMinutes) . "分钟前";
								}
								else
								{
									if (($spanSeconds >= 1))
									{
// 										return $String->format("%1$s秒前", floor$spanSeconds);
									    return floor($spanSeconds) . "秒前";
									}
									else
									{
										return "1秒前";
									}
								}
							}
						}
					}
				}
			}
		}
	}
	public static function ParseStringForName ($nameStr, $maxLen) // [String nameStr, int maxLen]
	{
	    if (is_null($nameStr))
		{
			return "";
		}
		$nStr = $nameStr->replaceAll(self::$RegEx_Replace_OnlyHSZX, "");
		if ((($maxLen > 0) && ($nStr->length() > $maxLen)))
		{
			return $nStr->substring(0, $maxLen);
		}
		return $nStr;
	}
	public static function ParseStringForNo_String_I ($noStr, $maxLen) // [String noStr, int maxLen]
	{
		if (is_null($noStr))
		{
			return "";
		}
		$nStr = $noStr->replaceAll(self::$RegEx_Replace_OnlySZX, "")->replaceAll(self::$RegEx_Replace_FirstXZ, "");
		if ((($maxLen > 0) && ($nStr->length() > $maxLen)))
		{
			return $nStr->substring(0, $maxLen);
		}
		return $nStr;
	}
	public static function CXmlFileToDataSet ($xmlFilePath) // [String xmlFilePath]
	{
		if (!DataType::IsNullOrEmpty($xmlFilePath))
		{
			try 
			{
				$ds = DataSet::constructor__();
				$ds->readXml($xmlFilePath);
				return $ds;
			}
			catch (\Exception $e)
			{
				throw $e;
			}
		}
		return NULL;
	}
}
DataType::__staticinit(); // initialize static vars for this class on load
?>
